<template>
  <div style="margin-top:20px">
    <el-form ref="form" label-width="80px" :model="form">
      <el-row>
        <el-col :span="24">
          <div class="grid-content bg-purple">
            <el-form-item label="名称" style="margin-right:15px">
              <el-input v-model="form.name" placeholder="请输入名称" :disabled="true" />
            </el-form-item>
          </div>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="24">
          <div class="grid-content bg-purple">
            <el-form-item label="手机号" style="margin-right:15px">
              <el-input v-model="form.phone" placeholder="请输入手机号" :disabled="true" />
            </el-form-item>
          </div>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="24">
          <div class="grid-content bg-purple">
            <el-form-item label="角色" style="margin-right:15px">
              <el-checkbox-group v-model="form.roleCodeList">
                <el-checkbox v-for="role in roleList" :key="role.code" :label="role.code" border disabled>{{ role.roleName }}</el-checkbox>
              </el-checkbox-group>
            </el-form-item>
          </div>
        </el-col>
      </el-row>

    </el-form>
  </div>
</template>
<script>
import Vue from 'vue'
import 'xe-utils'
import VXETable from 'vxe-table'
import 'vxe-table/lib/index.css'
import request from '@/utils/request'
Vue.use(VXETable)
export default {
  name: 'PartyDetail',
  data() {
    return {
      emptyForm: {},
      form: {
        name: '',
        phone: '',
        roleList: []
      },
      roleList: []
    }
  },
  created() {
    // 保存空表单对象
    this.emptyForm = JSON.parse(JSON.stringify(this.form))
  },
  methods: {
    // 获取页面信息
    getInfo(code) {
      // 查询到数据之前先展示空表单
      this.form = JSON.parse(JSON.stringify(this.emptyForm))
      // 查询角色信息
      this.getRoleList()
      request({ url: `/arpa-basic-api/party/${code}`, method: 'get' }).then(response => {
        this.form = response.data
      })
    },
    // 查询角色列表
    getRoleList() {
      request({ url: `/arpa-basic-api/role`, method: 'get', params: { 'type': 0 }}).then(response => {
        this.roleList = response.data.records
      })
    }
  }
}
</script>
<style lang="scss" scoped>
.dialog-footer {
  margin-top: 50px;
}
</style>
